package org.lmind.example.common.core;

import java.util.Enumeration;
import java.util.HashMap;

import org.apache.commons.collections.iterators.IteratorEnumeration;

public class HashMapAttributes implements WritableAttributes {
	
	private HashMap<String, Object> attributes = new HashMap<String, Object>();
	
	boolean dirty;
	
	boolean isDirty() {
		return dirty;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Enumeration<String> getNames() {
		return new IteratorEnumeration(attributes.keySet().iterator());
	}

	@Override
	public Object getValue(String name) {
		return attributes.get(name);
	}

	@Override
	public void setValue(String name, Object value) {
		attributes.put(name, value);
		dirty = true;
	}
	
	public void setIgnoreDirty(String name, Object value) {
		attributes.put(name, value);
	}

}
